package zhengyanze.com.aipoemmax.guide.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import zhengyanze.com.aipoemmax.R;
import zhengyanze.com.aipoemmax.guide.Constant;
import zhengyanze.com.aipoemmax.guide.activity.PoemDetilsActivity;
import zhengyanze.com.aipoemmax.guide.bean.PoemBean;
import zhengyanze.com.aipoemmax.guide.guide.BasLazyeFragment;
import zhengyanze.com.aipoemmax.guide.utils.TypefaceUtil;

import static zhengyanze.com.aipoemmax.guide.activity.PoemDetilsActivity.POEM_FRAGMENT_KEY;

/**
 * 原文
 * Created by MrZheng on 2017/7/22.
 */

public class Four1Fragment extends BasLazyeFragment {

    @BindView(R.id.tv_author)
    TextView tvAuthor;
    @BindView(R.id.tv_content)
    TextView tvContent;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.item_four, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        Bundle bundle = getArguments();
        PoemBean poemBean = bundle.getParcelable(POEM_FRAGMENT_KEY);
        String cont = poemBean.getContent();
        String regix = "([，|。|？|；|！])";

        tvAuthor.setText(poemBean.getAuthor());
        tvContent.setText(cont.replaceAll(regix, "$1\n").trim());

        TypefaceUtil util = new TypefaceUtil(getContext(), Constant.TTF.TTF_MAIN_TYPE);
        util.setTypeface(tvAuthor, false);
        util.setTypeface(tvContent, false);
    }

    @Override
    public void showAnimaort() {
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
